﻿@using System.Data;
@using GatewayServer.Common;
@using UtilsBase;
@{
    ViewBag.PageTitle = "洪峰智能";

    Layout = "~/Views/Shared/PageTemplate.cshtml";
}

<script>
    $(document).ready(function () {

        if ("@(ViewBag.order)" == "upd") {
            getEdit("@(ViewBag.edit_guid)");

        }

    });


    function getEdit(pguid) {
        $.post("getProduct", { "flag": Math.random(), guid: pguid }, function (result) {
            var myobj = (result.data);
            $("#p_name").val(myobj.p_name);
            $("#p_scene_name").val(myobj.p_scene_name);

            for (var i = 0; i < document.getElementById("p_status").options.length; i++) {
                if (document.getElementById("p_status").options[i].value == myobj.d_status) {
                    document.getElementById("p_status").options[i].selected = true;
                    break;
                }
                else {
                    document.getElementById("p_status").options[i].selected = false;

                }
            }
        });
    }
    function saveAll() {
        var data = $("#addForm").serializeArray(); //自动将form表单封装成json
        $.post("saveAll", data, function (result) {
            var jsonresult = (result);

            if (jsonresult.respCode == "200") {
                // $("#result").text("操作完成");
                window.location.href = "list";
                // window.history.back();
                alert("保存成功");
            }
            else {
                alert(jsonresult.respMsg);
                return;
            }
        });

    }
</script>

<style>
    #pagelist_follow {
        width: 100%;
    }

    #pagelist_main {
        width: 100%;
    }

    .kv-item label {
        width: 150px;
    }
</style>
<div id="saper-container">
    <form id="addForm" name="addForm" action="list" method="post">
        <input type="hidden" name="p_guid" id="p_guid" value="@ViewBag.edit_guid" />
        <div id="saper-hd"></div>
        <div id="saper-bd">
            <div class="subfiled clearfix">
                <h2>设备变量</h2>
            </div>
            <div class="subfiled-content">

                <div id="" title="添加/编辑">
                    <form action="" name="addForm" id="addForm" method="post">

                        <div class="kv-item clearfix">
                            <label><span class="impInfo">*</span>变量名称：</label>
                            <div class="kv-item-content">
                                <input type="text" name="v_name" id="v_name" placeholder="变量名称" />

                            </div>
                        </div>
                       @* <div class="kv-item clearfix">
                            <label><span class="impInfo">*</span>变量key：</label>
                            <div class="kv-item-content">
                                <input type="text" name="v_key" id="v_key" placeholder="变量key" /> 如：humidity
                            </div>
                        </div>
                        <div class="kv-item clearfix">
                            <label><span class="impInfo">*</span>变量值类型：</label>
                            <div class="kv-item-content">
                                <select id="v_value_type" name="v_value_type" style="width:130px;">
                                    <option value="number">number</option>
                                    <option value="bool">bool</option>
                                </select>

                            </div>
                        </div>
                        <div class="kv-item clearfix">
                            <label><span class="impInfo">*</span>变量功能：</label>
                            <div class="kv-item-content">
                                <select id="v_export" name="v_export" style="width:130px;">
                                    <option value="0">传感器值</option>
                                    <option value="1">执行器状态</option>
                                </select>

                            </div>
                        </div>
                        <div class="kv-item clearfix">
                            <label><span class="impInfo">*</span>变量单位：</label>
                            <div class="kv-item-content">
                                <input type="text" name="v_unit" id="v_unit" placeholder="变量单位" /> 如：℃
                            </div>
                        </div>
                        <div class="kv-item clearfix">
                            <label><span class="impInfo">*</span>状态：</label>
                            <div class="kv-item-content">
                                <select id="v_status" name="v_status" style="width:130px;">
                                    <option value="0">启用</option>
                                    <option value="1">禁用</option>
                                </select>

                            </div>
                        </div>*@

                        <div class="kv-item clearfix">
                            <label ><span class="impInfo"></span>LOGO：</label>
                            <div class="kv-item-content">
                                <a href="javascript:;" class="aFile-upload" style="float:left">
                                    <span id="sp_img" style=""><img src="/common/images/addfile.png" style="vertical-align:middle" /></span>
                                    <input type="file" name="file_uploadLogo" id="file_uploadLogo" onchange="uploadChange(this,'file_uploadLogo_progress','fileurlLogo','Div_showImgLogo',1)" multiple="multiple">上传图片
                                </a>
                                <div style="float:right">
                                    <img src="" id="file_uploadLogo_progress" style="display: none; width: 25px; height: 25px; vertical-align: middle;" />
                                    <input type="hidden" id="fileurlLogo" name="fileurlLogo" value="" />
                                </div>
                            </div>
                            <div id="Div_showImgLogo"></div>
                        </div>
                        <div><hr /></div>
                        <div style="margin:0 auto;width:150px;">

                            <input type="button" id="save" name="save" value="保存" onclick="javascript:saveAll()" />
                            &nbsp;&nbsp; <input type="button" id="but_back1" name="but_back1" value="返回" onclick="javascript:window.history.back()" />
                        </div>

                    </form>
                </div>
            </div>
        </div>
        <div id="saper-ft"></div>
    </form>
</div>

